<%-- 
    Document   : StartTest
    Created on : Mar 23, 2012, 1:11:36 AM
    Author     : Tri ben tre
--%>

<%@page import="COMMON.NganHangCauHoi"%>
<%@page import="COMMON.CauHoi"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<div id="content">
    <% float score = Float.parseFloat(request.getAttribute("score").toString()); %>
    <h3>Test your English - Answers (Exam code: <%= request.getAttribute("examCode")%>) </h3>
    <div><b>Right: <%= request.getAttribute("result") %> - Score: <%= score %> - Result: <% if(score > 5) out.println("Pass"); else out.println("Failed"); %></b></div>
    <p>Here are the answers to the test.
        <br> The correct answers shown by a tick <img src='./Template/images/tick-green.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>, the wrong answers are shown by a cross <img src='./Template/images/cross-red.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>.
        <br>The results that you chose are also shown for each question, so you can compare your own answers with the correct ones</p>
    <br><br>                
    <%
        int examCode = Integer.parseInt(request.getAttribute("examCode").toString());
        ArrayList<CauHoi> dsch = (ArrayList<CauHoi>) request.getAttribute("dsch");
        String answer = (String) request.getAttribute("answer");
        String[] str = answer.split(",");
        
        for (int i = 1; i <= dsch.size(); i++) {
            CauHoi ch = dsch.get(i - 1);
    %>

    <div class="post_box">
        <div class="post_meta"><%= i%>.<%= ch.getQuestion()%> (<% if (ch.getLevel() == 1) {
                out.println("Easy");
            } else if (ch.getLevel() == 2) {
                out.println("Medium");
            } else if (ch.getLevel() == 3) {
                out.println("Hard");
            }%>)</div>
        <div><% if (ch.getResult() == 1) {
                out.println("<img src='./Template/images/tick-green.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>");
            } else {
                out.println("<img src='./Template/images/cross-red.gif' width='20' height='18' style='border-style:none;padding:0px;'>");
                            }%><input type="radio" name="<%= i%>" id="answerA<%= i%>" value="1" <% if (str[i - 1].equals("1")) {
                                    out.println("checked='checked'");
                                }%> /><label for="answerA<%= i%>" class="opt"><%= ch.getAnswer_1()%></label></div>
        <div><% if (ch.getResult() == 2) {
                out.println("<img src='./Template/images/tick-green.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>");
            } else {
                out.println("<img src='./Template/images/cross-red.gif' width='20' height='18' style='border-style:none;padding:0px;'>");
            }%><input type="radio" name="<%= i%>" id="answerB<%= i%>" value="2" <% if (str[i - 1].equals("2")) {
                                out.println("checked='checked'");
                            }%>/><label for="answerB<%= i%>" class="opt"><%= ch.getAnswer_2()%></div>
        <div><% if (ch.getResult() == 3) {
                out.println("<img src='./Template/images/tick-green.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>");
            } else {
                out.println("<img src='./Template/images/cross-red.gif' width='20' height='18' style='border-style:none;padding:0px;'>");
            }%><input type="radio" name="<%= i%>" id="answerC<%= i%>" value="3" <% if (str[i - 1].equals("3")) {
                                out.println("checked='checked'");
                            }%>/><label for="answerC<%= i%>" class="opt"><%= ch.getAnswer_3()%></label></div>
        <div><% if (ch.getResult() == 4) {
                out.println("<img src='./Template/images/tick-green.gif' width='20' height='18' border='0' style='border-style:none;padding:0px;'>");
            } else {
                out.println("<img src='./Template/images/cross-red.gif' width='20' height='18' style='border-style:none;padding:0px;'>");
            }%><input type="radio" name="<%= i%>" id="answerD<%= i%>" value="4" <% if (str[i - 1].equals("4")) {
                                out.println("checked='checked'");
                            }%>/><label for="answerD<%= i%>" class="opt"><%= ch.getAnswer_4()%> from</label></div>
        <div class="cleaner"></div>
    </div>
    <%
        }
    %>
    <div style="text-align: right;"><button>Finish and view result</button></div>
    <div><input type="hidden" value="<%= request.getAttribute("examCode")%>" name="examCode" id="examCode"/></div>
</div>
